import Vue from 'vue'
import Router from 'vue-router'
import index from '../components/index/index.vue';//首页
import detail from  '../components/detail/detail.vue';//详情页
import detaiFeaturel from '../components/detail/detaiFeaturel/detaiFeaturel.vue'
import detailContent from '../components/detail/detailContent/detailContent.vue'
import detail_myMaterials from '../components/detail/detail_myMaterials/detail_myMaterials.vue'
import feature from  '../components/feature/feature.vue';//我的特征库
import engineering_index from '../components/engineering-index/engineering-index.vue';
import target_set from '../components/target-set/target-set.vue'
import all404 from '../components/common/404/404.vue'
import login from '../components/login/login.vue'
import my from '../components/My/My.vue'

Vue.use(Router)

const router =  new Router({
  // mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '*',
      redirect: '/all404'
    },
    {
      path: '/login',
      name: 'login',
      meta: {title: '广州地铁大数据移动平台APP-登陆'},
      component: login,
    },
    {
      path: '/all404',
      name: 'all404',
      meta: {title: '广州地铁大数据移动平台APP'},
      component: all404,
    },
    {
      path: '/index',
      name: 'index',
      meta: {title: '广州地铁大数据移动平台APP',},
      component: index,
    },
    {
      path: '/detail',
      name: 'detail',
      meta: {title: '广州地铁大数据移动平台APP-指标详情',},
      component: detail,
    },
    {
      path: '/detaiFeaturel',
      name: 'detaiFeaturel',
      meta: {title: '广州地铁大数据移动平台APP-指标详情'},
      component: detaiFeaturel,
    },
    {
      path: '/detailContent',
      name: 'detailContent',
      meta: {title: '广州地铁大数据移动平台APP-指标详情'},
      component: detailContent,
    },
    {
      path: '/detail_myMaterials',
      name: 'detail_myMaterials',
      meta: {title: '广州地铁大数据移动平台APP-我的主材'},
      component: detail_myMaterials,
    },
    {
      path: '/feature',
      name: 'feature',
      meta: {title: '广州地铁大数据移动平台APP-我的特征库'},
      component: feature,
    },
    {
      path:'/engineering_index',
      name:'engineering_index',
      meta: {title: '广州地铁大数据移动平台APP-工程指标'},
      component:engineering_index,
    },
    {
      path:'/target_set',
      name:'target_set',
      meta: {title: '广州地铁大数据移动平台APP-指标设置'},
      component:target_set,
    },
    {
      path:'/my',
      name:'my',
      meta: {title: '广州地铁大数据移动平台APP-我的'},
      component:my,
    },
  ],
  // scrollBehavior (to, from, savedPosition) {
  //   return { x: 0, y: 0 }
  // },
})

router.beforeEach(function(to,from,next){
  if(to.meta.title){
    document.title = to.meta.title
  }else{
    document.title = '广州地铁大数据移动平台APP'
  }
  next()
})


export default router;
